<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<div id="app">
  <cpn ref="aaa"></cpn>
  <cpn></cpn>
  <cpn></cpn>
  <button @click="btnClick">按钮</button>
</div>
<template id="cpn">
  <div>
    我是子组件
  </div>
</template>
<script src="../js/vue.js"></script>
<script>
  const cpn = {
    template: '#cpn',
    data() {
      return {
        name: '哈哈哈'
      }
    },
    methods: {
      showMessage() {
       console.log('我是子组件')
      }
    },
    props: {}
  }
  const app = new Vue({
    el: '#app',
    data: {
      message: "你好",
    },
    components: {
      cpn
    },
    methods: {
      btnClick () {
        // 父亲访问子
        // 1、$children(不建议)
        // 2、$refs
        console.log(this.$refs.aaa)
        // for (let c of this.$children) {
        //   console.log(c.name)
        // }
      }
    }
  })
</script>
</body>
</html>
